//
//  new1.cpp
//  test_cpp
//
//  Created by Camille Xu on 2023/4/18.
//  Copyright © 2023年 Camille Xu. All rights reserved.
//

// 方阵压缩成一维之后，返回相乘结果（即将原结果压缩成一维）。

#include <iostream>
#include <vector>
#include <string>
#include <limits.h>
#include <map>
#include <cmath>
using namespace std;

vector<float> getAns(vector<float> a, vector<float> b) {
    int m = sqrt(a.size());
    vector<float> res(m * m);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            int sum = 0;
            for (int t = 0; t < m; ++t) {
                sum += a[i * m + t] * b[t * m + j];
            }
        res[i * m + j] = sum;
        }
    }
    return res;
}

int main() {
    vector<float> a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector<float> b = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector<float> ans = getAns(a, b);
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << " ";
    }
    return 0;
}
